<html>
<head>
	<title>WargclubArgentina> Login</title>
	<link href="css/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
	<!-- start header div -->	
	<div id="header">
		<h2>WargclubArgentina> Login</h2>
	</div>
	<!-- end header div -->		
	<!-- start wrap div -->	
	<div id="wrap">
	    <!-- start PHP code -->
<?php
	    	mysql_connect("localhost", "wargclub_root", "33205524rox") or die(mysql_error()); // Connect to database server(localhost) with username and password.
			mysql_select_db("wargclub_gestion") or die(mysql_error()); // Select registration database.
			if(isset($_POST['username']) && !empty($_POST['username']) AND isset($_POST['password']) && !empty($_POST['password'])){
				$user = mysql_escape_string($_POST['username']);
				$password = mysql_escape_string(md5($_POST['password']));			
				$activo=activo";
				$search = mysql_query("SELECT username, password, active FROM users WHERE username='".$user."' AND password='".$password."' AND active=$activo) or die(mysql_error()); 
				$match  = mysql_num_rows($search);				
				if($match > 0){
   					$msg = 'Login Exitoso!';
					}
					else{
					$msg = 'Login Failed!<br /> Por favor asegurese que ha ingresado los datos correctos o que la cuenta ha sido activada.';
				}
			} 
?>
	    <!-- stop PHP Code -->	
		<!-- title and description -->	
		<h2>Ingrese aqui</h2>
		<p>Por favor ingrese su nombre y password para ingresar:</p>
		<?php 
			if(isset($msg)){ // Check if $msg is not empty
				echo '<div class="statusmsg">'.$msg.'</div>'; // Display our message and add a div around it with the class statusmsg		       
			} ?>
		
		<!-- start sign up form -->	
		<form action="" class="form"method="post">
			<label for="name">Nombre:</label>
			<input type="text" name="name" value="" />
			<label for="password">Password:</label>
			<input type="password" name="password" value="" />
			<input type="submit" class="submit_button" value="Login" /><br/>
		        <a href="changepassword.php">Cambiar password</a>
		
		
		<!-- end sign up form -->	
		
	</div>
	<!-- end wrap div -->	
</body>
</html>